package com.telsoft.hms.service;

import java.util.Date;
import java.util.List;

import com.sun.org.apache.xpath.internal.functions.FuncCeiling;
import com.telsoft.hms.entity.AMObject;
import com.telsoft.hms.entity.ETT_Bookmark;
import com.telsoft.hms.entity.ETT_Language;
import com.telsoft.hms.entity.ETT_Title;
import com.telsoft.hms.entity.ETT_Widget;
import com.telsoft.hms.entity.Patient;
import com.telsoft.hms.function.FUNC_Widget;
import com.telsoft.hms.function.HMS_Bookmark_FUNC;
import com.telsoft.hms.function.HMS_Language_FUNC;
import com.telsoft.hms.function.HMS_Title_FUNC;
import com.telsoft.hms.function.HMS_News_FUNC;

public class SService {
	private final HMS_Title_FUNC hmsTitle;
	private final HMS_Bookmark_FUNC hmsBookmark;
	private final HMS_News_FUNC hmsNews;
	private final FUNC_Widget funcWidget;

	public SService() {
		hmsTitle = new HMS_Title_FUNC();
		hmsBookmark = new HMS_Bookmark_FUNC();
		hmsNews = new HMS_News_FUNC();
		funcWidget = new FUNC_Widget();
	}

	public com.telsoft.hms.entity.ETT_GetDataLoginRT getDataLogin(
			long lCurrentHospitalId, int dcLanguageCode, String sStatus) {
		return new com.telsoft.hms.function.HMS_Login().getDataLogin(
				lCurrentHospitalId, dcLanguageCode, sStatus);
	}

	public com.telsoft.hms.entity.ETT_AddRegisRT addRegis(
			com.telsoft.hms.entity.RegisFullContract regisFullContract,
			List<com.telsoft.hms.entity.OrderServiceContract> lService,
			List<com.telsoft.hms.entity.OrderServiceDltContract> lDlt,
			String strKey) throws Exception {

		return new com.telsoft.hms.function.HMS_RM().addRegis(
				regisFullContract, lService, lDlt, strKey);

	}

	public String login(String strUsername, String strPassword,
			int iLanguageCode) throws Exception {
		return new com.telsoft.hms.function.HMS_Login().login(strUsername,
				strPassword, iLanguageCode);
	}

	public com.telsoft.hms.entity.AMObject[] getAllObjectByUsername(
			String strKey, String username) throws Exception {
		return new com.telsoft.hms.function.HMS_AMObject()
				.getAllObjectTree(strKey);
	}

	public String[] getAuthorizator(String strKey, String username,
			String objectPath) throws Exception {
		return new com.telsoft.hms.function.HMS_Authorizator().getAuthorizator(
				strKey, objectPath);
	}

	public Patient[] searchPatient(String strKey, String username, Date start,
			Date end, String patientCode, String fullName, String idNo,
			String passportNo, String pin, String phone, String email,
			String address, String hieNo) throws Exception {
		return new com.telsoft.hms.function.HMS_Patient().searchPatient(strKey,
				start, end, patientCode, fullName, idNo, passportNo, pin,
				phone, email, address, hieNo);
	}

	public ETT_Language[] getListLanguage(String hospitalKey, int languageCode)
			throws Exception {
		return new HMS_Language_FUNC().getListLanguage(hospitalKey,
				languageCode);
	}

	public ETT_Title[] getListTitle(String securityKey, String userName)
			throws Exception {
		return hmsTitle.getListTitle(securityKey, userName);
	}

	public long addOrUpdateTitle(String securityKey, String userName,
			ETT_Title title) throws Exception {
		return hmsTitle.addOrUpdateTitle(securityKey, userName, title);
	}

	public void deleteTitle(String securityKey, String userName, long[] lTitleId)
			throws Exception {
		hmsTitle.deleteTitle(securityKey, userName, lTitleId);
	}

	public ETT_Title[] getListTitleLanguage(String securityKey,
			String userName, long titleId) throws Exception {
		return hmsTitle.getListTitleLanguage(securityKey, userName, titleId);
	}

	public long addTitleLanguage(String securityKey, String userName,
			ETT_Title title) throws Exception {
		return hmsTitle.addTitleLanguage(securityKey, userName, title);
	}

	public long updateTitleLanguage(String securityKey, String userName,
			ETT_Title title) throws Exception {
		return hmsTitle.updateTitleLanguage(securityKey, userName, title);
	}

	public void deleteTitleLanguage(String securityKey, String userName,
			long titleId, int[] lLanguageCode) throws Exception {
		hmsTitle.deleteTitleLanguage(securityKey, userName, titleId,
				lLanguageCode);
	}

	public ETT_Bookmark[] getAllBookmark(String strKey) throws Exception {
		return hmsBookmark.getAllBookmark(strKey);
	}

	public int deleteBookmark(String strKey, String strPath) throws Exception {
		return hmsBookmark.deleteBookmark(strKey, strPath);
	}

	public int addBookmark(String strKey, ETT_Bookmark bookmark)
			throws Exception {
		return hmsBookmark.addBookmark(strKey, bookmark);
	}

	// Thêm sửa xóa tin tức
	public void deleteNews(String strSecurityKey, long lId, int languageCode)
			throws Exception {
		hmsNews.deleteNews(strSecurityKey, lId, languageCode);
	}

	public AMObject[] getWidgetRightByUser(String strSecurityKey)
			throws Exception {
		return funcWidget.getWidgetRightByUser(strSecurityKey);
	}

	public ETT_Widget[] getAllWidget(String strSecurityKey) throws Exception {
		return funcWidget.getAllWidget(strSecurityKey);
	}

	public boolean updateWidgetLocation(String strSecurityKey,
			List<ETT_Widget> lstWidget) throws Exception {
		return funcWidget.updateWidgetLocation(strSecurityKey, lstWidget);
	}
}
